package dao.impl;

import java.sql.Connection;
import java.sql.PreparedStatement;

import javax.sql.DataSource;

import dao.*;

public class StudentDaoImpl implements StudentDao {
	private DataSource dataSource;

	public DataSource getDataSource() {
		return dataSource;
	}

	public void setDataSource(DataSource dataSource) {
		this.dataSource = dataSource;
	}

	@Override
	public void insertStudents(String sql) {
		Connection connection = null;
		PreparedStatement statement = null;
		try {
			connection = (Connection) dataSource.getConnection();
			statement = (PreparedStatement) connection.prepareStatement(sql);
			statement.executeUpdate();
			statement.close();
			connection.close();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}